<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:th="http://www.thymeleaf.org">
<head th:include="/include/commonHeader::commonHeader('人员冲突编辑')"></head>
<body>
<div class="wrapper wrapper-content">
    <div class="col-sm-12">
        <form class="form-horizontal m-t" id="exampleForm">
            <input id="workcode" name="workcode"  type="hidden" th:value="${crew.workcode}">
            <div class="form-group">
                <label class="col-xs-3 control-label">部门：</label>
                <div class="col-xs-8">
                    <input id="depName" name="depName" class="form-control" type="text" th:value="${crew.depName}" disabled>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-3 control-label">人员：</label>
                <div class="col-xs-8">
                    <input id="cName" name="cName" class="form-control" type="text" th:value="${crew.cName}" disabled>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-3 control-label">排班授权：</label>
                <div class="col-xs-8">
                    <input id="techZName" name="techZName" class="form-control" type="text" th:value="${crew.techZName}" disabled>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-3 control-label">是否管理员：</label>
                <div class="col-xs-8">
                    <select id="management" name="management"　class="form-control" th:value="${crew.management}">
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <div class="text-center">
                    <button id="btn_save" onclick="save()" type="button" class="btn btn-primary">提交</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script src="/plugins/bootstrapValidator/js/bootstrapValidator.min.js"></script>
<script src="/plugins/bootstrapValidator/js/language/zh_CN.js"></script>
<!-- 自定义js -->
<script th:inline="javascript">
    var prefix = "/crewManagement";
    var isReadonly = "[[${isReadonly}]]";//页面是否只能查看
    $(function () {
        var management = "[[${crew.management}]]";
        if(management != null){
            if(management == 'true'){
                $("#management").val('1');
            }else {
                $("#management").val('0');
            }
        }

    });
    //保存
    function save() {
        $.ajax({
            cache: true,
            type: "POST",
            url: prefix + "/update.do",
            data: {
                workcode : $("#workcode").val(),
                management : $("#management").val(),
            },
            error : function(request) {
                toastr.error("保存失败");
            },
            success : function(data) {
                if (data.code == 0) {
                    parent.toastr.success("操作成功");
                    parent.reload();
                    var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                    parent.layer.close(index);
                } else {
                    toastr.warning(data.msg)
                }
            }
        });
    }



</script>
</body>
</html>
